package main

import (
	"Ljohn/modeTest/FuncionalOptionsTest"
	"Ljohn/modeTest/decorator"
	"Ljohn/modeTest/visitor"
	"fmt"
)

func Hello(s string) {
	fmt.Println(s)
}

func functionalTest() {
	fn1 := FuncionalOptionsTest.CheckId(3)
	fn2 := FuncionalOptionsTest.CheckName("pig")
	fn3 := func(arg int) FuncionalOptionsTest.CheckFunc {
		return func(a *FuncionalOptionsTest.Act) (err error) {
			fmt.Println("---我还想做点其他事")
			fmt.Println(arg)
			return
		}
	}(1)
	FuncionalOptionsTest.Exec("pig", fn1, fn2, fn3)
}

func decoratorTest() {
	f1 := decorator.Decorator(Hello)
	f2 := decorator.Decorator(Hello)
	f1("aa")
	f2("ss")
}

func visitorTest() {
	c := visitor.Circle{10}
	/*	r := visitor.Rectangle{100, 200}
		shapes := []visitor.Shape{c, r}

		for _, s := range shapes {
			s.Accept(visitor.JsonVisitor)
			s.Accept(visitor.XmlVisitor)
		}*/
	_ = c
	var o visitor.Shape
	o = visitor.OtherInfo{nil, 1}
	o = visitor.OtherInfo1{o, 2}
	o = visitor.OtherInfo2{o, 3}
	o.Accept(visitor.PrintSome)
}

func visitorK8sTest() {
	info := visitor.Info{}
	var v visitor.Visitor = &info
	v = visitor.LogVisitor{v}
	v = visitor.NameVisitor{v}
	v = visitor.OtherThingsVisitor{v}

	loadFile := func(info *visitor.Info, err error) error {
		info.Name = "Test"
		info.Namespace = "TTT"
		info.OtherThings = "We are running as remote team."
		return nil
	}
	v.Visit(loadFile)

}

func main() {
	decoratorTest()
	test1()
	//functionalTest()
	//decoratorTest()
	//visitorTest()

	//visitorK8sTest()
}

func test1() {
	FuncionalOptionsTest.TestInter()
}
